package com.zs.manager;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.zs.ICallBack;

/**
 * 回调对象管理类
 * 
 * @author LENOVO
 *
 */
public class CallBackManager {
	private static final Map<Integer, ICallBack> callBackPool = new ConcurrentHashMap<Integer, ICallBack>();

	private static CallBackManager instance;

	public static CallBackManager getInstance() {
		if (instance == null) {
			synchronized (CallBackManager.class) {
				if (instance == null) {
					instance = new CallBackManager();
				}
			}
		}

		return instance;
	}

	public void setCallBack(int seq, ICallBack callBack) {
		callBackPool.put(seq, callBack);
	}

	public ICallBack getCallBack(int seq) {
		return callBackPool.get(seq);
	}

	public void unregisterCallBack(int seq) {
		callBackPool.remove(seq);
	}
}
